import Vue from 'vue'
import Router from 'vue-router'

const Login = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/login'], () => {
    resolve(require('@/pages/login'))
  })
}

const NotFound = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/404'], () => {
    resolve(require('@/pages/404'))
  })
}

const Index = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/index'], () => {
    resolve(require('@/pages/index'))
  })
}

const Home = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/home/home'], () => {
    resolve(require('@/pages/home/home'))
  })
}

const Page1 = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/parkRecord/page1'], () => {
    resolve(require('@/pages/parkRecord/page1'))
  })
}

const ParkDetail = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/parkRecord/parkDetail'], () => {
    resolve(require('@/pages/parkRecord/parkDetail'))
  })
}

const TotalParkRecord = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/queryParkRecord/totalParkRecord'], () => {
    resolve(require('@/pages/queryParkRecord/totalParkRecord'))
  })
}

const UserManage = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/userManage'], () => {
    resolve(require('@/pages/systemManage/userManage'))
  })
}

const UserManageAE = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/userManage-AE'], () => {
    resolve(require('@/pages/systemManage/userManage-AE'))
  })
}

const UserManageView = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/userManage-view'], () => {
    resolve(require('@/pages/systemManage/userManage-view'))
  })
}

const FuncManage = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/funcManage'], () => {
    resolve(require('@/pages/systemManage/funcManage'))
  })
}

const FuncManageAE = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/funcManage-AE'], () => {
    resolve(require('@/pages/systemManage/funcManage-AE'))
  })
}
const RoleManage = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/roleManage'], () => {
    resolve(require('@/pages/systemManage/roleManage'))
  })
}

const RoleManageAE = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/roleManage-AE'], () => {
    resolve(require('@/pages/systemManage/roleManage-AE'))
  })
}
const RegionManage = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/regionManage'], () => {
    resolve(require('@/pages/systemManage/regionManage'))
  })
}

const RegionManageAE = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/regionManage-AE'], () => {
    resolve(require('@/pages/systemManage/regionManage-AE'))
  })
}

const RegionManageView = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/systemManage/regionManage-view'], () => {
    resolve(require('@/pages/systemManage/regionManage-view'))
  })
}

const TotalMember = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/memberManage/totalMember.vue'], () => {
    resolve(require('@/pages/memberManage/totalMember.vue'))
  })
}

const Channel = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/channelReceiStatistics/channel'], () => {
    resolve(require('@/pages/channelReceiStatistics/channel'))
  })
}

const DataList = resolve => {
  // require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
  // （代码分块）
  require.ensure(['@/pages/channelReceiStatistics/dataList'], () => {
    resolve(require('@/pages/channelReceiStatistics/dataList'))
  })
}
Vue.use(Router)

export default new Router({
	mode: 'history',
	routes: [{
		path: '/',
		name: 'Login',
		component: Login,
		hidden: true
	}, {
        path: '/404',
        component: NotFound,
        name: '',
        hidden: true
   },
    {
        path: '*',
        hidden: true,
        redirect: { path: '/404' }
    }, {
		path: '/',
		component: Index,
		name: '概览',
		iconCls: 'icon-shouye', // 图标样式class
		leaf: true, // 只有一个节点 
		children: [{
			path: '/home',
			component: Home,
			name: '概览'
		}]
	}, {
		path: '/',
		component: Index,
		name: '停车场查询',
		iconCls: 'icon-qiche', // 图标样式class
		children: [{
			path: '/page1',
			component: Page1,
			name: 'Page1'
		}, {
				path: '/parkDetail',
				component: ParkDetail,
				name: 'ParkDetail'
			}]
	}, {
		path: '/',
		component: Index,
		name: '停车记录查询',
		iconCls: 'icon-jilu', // 图标样式class
		children: [{
			path: '/totalParkRecord',
			component: TotalParkRecord,
			name: 'TotalParkRecord'
		}]
	}, {
		path: '/',
		component: Index,
		name: '会员管理',
		iconCls: 'icon-huiyuan', // 图标样式class
		children: [{
			path: '/totalMember',
			component: TotalMember,
			name: 'TotalMember'
		}]
	}, {
		path: '/',
		component: Index,
		name: '财务结算',
		iconCls: 'icon-Settlement', // 图标样式class
		children: [{
			path: '/channel',
			component: Channel,
			name: 'Channel'
	}, {
			path: '/dataList',
			component: DataList,
			name: 'DataList'
		}]
	}, {
		path: '/',
		component: Index,
		name: '系统管理',
		iconCls: 'icon-huiyuan', // 图标样式class
		children: [{
			path: '/userManage',
			component: UserManage,
			name: '系统用户管理'
		}, {
			path: '/userManageAE',
			component: UserManageAE,
			name: '系统用户管理编辑'
		}, {
			path: '/userManageView',
			component: UserManageView,
			name: '系统用户管理查看'
		}, {
			path: '/funcManage',
			component: FuncManage,
			name: '功能注册'
		}, {
			path: '/funcManageAE',
			component: FuncManageAE,
			name: '功能注册管理编辑'
		}, {
			path: '/roleManage',
			component: RoleManage,
			name: '角色管理'
		}, {
			path: '/roleManageAE',
			component: RoleManageAE,
			name: '角色管理编辑'
		}, {
			path: '/regionManage',
			component: RegionManage,
			name: '区域管理'
		}, {
			path: '/regionManageAE',
			component: RegionManageAE,
			name: '区域管理编辑'
		}, {
			path: '/regionManageView',
			component: RegionManageView,
			name: '区域管理编辑'
		}]
		
	}]
})
